<?php
declare(strict_types=1);
namespace Field;

class SysUserAuthConst
{
    public const pk='AuthID';
    public const index=['AuthID'];
	public const fields=['AuthID','UserID','CreateAt','UpdateAt','IsSubscribe','LastAt','TypeID','OpenID','SessionKey','ShopID'];
	public const comment=['AuthID'=>'','UserID'=>'sys_user|m|','CreateAt'=>'时间','UpdateAt'=>'','IsSubscribe'=>'平台','LastAt'=>'最后交互时间','TypeID'=>'平台','OpenID'=>'第三方OpenID','SessionKey'=>'SessionKey','ShopID'=>''];
	/*
    * @Field AuthID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const AuthID = 'AuthID';
    /*
    * @Field UserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment sys_user|m|
    */
    public const UserID = 'UserID';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field IsSubscribe
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 平台
    */
    public const IsSubscribe = 'IsSubscribe';
    /*
    * @Field LastAt
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 最后交互时间
    */
    public const LastAt = 'LastAt';
    /*
    * @Field TypeID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 平台
    */
    public const TypeID = 'TypeID';
    /*
    * @Field OpenID
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 第三方OpenID
    */
    public const OpenID = 'OpenID';
    /*
    * @Field SessionKey
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment SessionKey
    */
    public const SessionKey = 'SessionKey';
    /*
    * @Field ShopID
    * @Type bigint(20)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const ShopID = 'ShopID';
}

class SysUserAuthColumns
{
public  int $AuthID;
   public  int $UserID=0;
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
   public  int $IsSubscribe=0;
   public  int $LastAt=0;
   public  int $TypeID=0;
   public  ?string $OpenID='';
   public  ?string $SessionKey='';
   public  int $ShopID=0;
	public function toArray():array
	{
		return [
'AuthID'=>$this->AuthID,
    'UserID'=>$this->UserID,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,
    'IsSubscribe'=>$this->IsSubscribe,
    'LastAt'=>$this->LastAt,
    'TypeID'=>$this->TypeID,
    'OpenID'=>$this->OpenID,
    'SessionKey'=>$this->SessionKey,
    'ShopID'=>$this->ShopID,        ];
	}
}

class SysUserAuthRow
{
	public SysUserAuthColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'AuthID' => $this->data->AuthID,
        'UserID' => $this->data->UserID,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt,
        'IsSubscribe' => $this->data->IsSubscribe,
        'LastAt' => $this->data->LastAt,
        'TypeID' => $this->data->TypeID,
        'OpenID' => $this->data->OpenID,
        'SessionKey' => $this->data->SessionKey,
        'ShopID' => $this->data->ShopID, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysUserAuthColumns();
        isset($data['AuthID']) && $this->data->AuthID = (int)$data['AuthID'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['IsSubscribe']) && $this->data->IsSubscribe = (int)$data['IsSubscribe'];
           isset($data['LastAt']) && $this->data->LastAt = (int)$data['LastAt'];
           isset($data['TypeID']) && $this->data->TypeID = (int)$data['TypeID'];
           isset($data['OpenID']) && $this->data->OpenID = (string)$data['OpenID'];
           isset($data['SessionKey']) && $this->data->SessionKey = (string)$data['SessionKey'];
           isset($data['ShopID']) && $this->data->ShopID = (int)$data['ShopID'];
    }
}
?>